import {
  getEntireDepartments,
  getEntireMenus,
  getEntireRoles
} from '@/service/main/main'

import { defineStore } from 'pinia'
interface IMainState {
  entireRoles: any[]
  entireDepartments: any[]
  entireMenus: any[]
}
const useMainStore = defineStore('main', {
  state: (): IMainState => ({
    entireDepartments: [],
    entireRoles: [],
    entireMenus: []
  }),

  actions: {
    // 获取所有角色列表和部门
    async fetchEntireDataAction() {
      const rolesRelust = await getEntireRoles()
      const departmentsRelust = await getEntireDepartments()
      const MenusRelust = await getEntireMenus()
      // console.log(rolesRelust, departmentsRelust)
      this.entireRoles = rolesRelust.data.list
      this.entireDepartments = departmentsRelust.data.list
      this.entireMenus = MenusRelust.data.list
      // console.log(this.entireMenus)
    }
  }
})

export default useMainStore
